#ifndef MYSQL_H
#define MYSQL_H

#include <QtSql>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QDebug>
#include <QMessageBox>
class MySql : public QObject
{
    Q_OBJECT
public:
    static MySql* gethand(){
        if(sqlhand == nullptr){
            sqlhand = new MySql();
        }
        return sqlhand;
    }
     bool initsql();
     void createTable();
     void dropTable();
     void insertTable(QString name1,QString name2,QString mes,QString time);
     QString getChatRecord(QString myname, QString hisname);
private:
    explicit MySql(QObject *parent = nullptr);
    static MySql* sqlhand;
    QSqlQuery *query;
    QSqlDatabase database;
    QSqlQuery* sqlquery;
    QString tableName;

};

#endif // MYSQL_H
